import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import cfxpool from '@/util/cfxpool'
import 'normalize.css'
Vue.config.productionTip = false
const init = async() => {
  const r = await cfxpool.oneKeyInit({
    chainChanged: () => {
      window.location.reload()
    },
    accountsChanged: () => {
      window.location.reload()
    }
  })
  if (!r) {
    console.log('请安装onekey')
    return
  }

  console.log(r)

  store.dispatch('app/setCfxToolInit', true)

  cfxpool.selectedAddress().then(res => {
    console.log(res)
    if (res.length > 0) {
      store.dispatch('app/setAddress', res[0])
    }
  })
}

init()

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
